﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using ATSModel;
using ATSBLL;
using System.Collections.Generic;
using ATSModel.T_ReportInfo;

public partial class TestDataReport_PIMReport_PIMRepairReport : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
     
    }
    protected void BtuQuery_Click(object sender, EventArgs e)
    {
        CrystalReportViewer.DisplayToolbar = true;
        CrystalReportSource.ReportDocument.Load(Server.MapPath("PIMRepairReport.rpt"));
        if (tbSta.Value == "" || tbEnd.Value == "")
        {
       
            ScriptManager.RegisterStartupScript(UpdatePanel1,
                        GetType(), "click", "<script>alert('" + "请先选择起始与终止日期！" + "');</script>", false); 
            return;
        }
        IList<PIMRepairInfo> list = GetDataInfo();//GetDataByDateInfo();

        this.CrystalReportSource.ReportDocument.SetDataSource(list);
        this.CrystalReportSource.DataBind();
        this.CrystalReportViewer.ReportSource = CrystalReportSource;
        this.CrystalReportViewer.DataBind();
        this.CrystalReportViewer.Visible = true;
    }
    protected void BtuAll_Click(object sender, EventArgs e)
    {
        CrystalReportViewer.DisplayToolbar = true;
        this.CrystalReportSource.ReportDocument.Load(Server.MapPath("PIMRepairReport.rpt"));
        IList<PIMRepairInfo> list = GetAllDataInfo();

        this.CrystalReportSource.ReportDocument.SetDataSource(list);
        this.CrystalReportSource.DataBind();
        this.CrystalReportViewer.ReportSource = CrystalReportSource;
        this.CrystalReportViewer.DataBind();
        this.CrystalReportViewer.Visible = true;
    }

    //protected IList<PIMRepairInfo> GetDataByDateInfo()
    //{
    //    DateTime dt1 = DateTime.Parse(TextBox1.Value.Trim());
    //    DateTime dt2 = DateTime.Parse(TextBox2.Value.Trim());

    //    IList<PIMRepairInfo> Info = new List<PIMRepairInfo>();
    //    PIMRepairData rdP = new PIMRepairData();
    //    Info = rdP.GetPIMRepairInfo(dt1, dt2);
    //    return Info;
    //}

    protected IList<PIMRepairInfo> GetAllDataInfo()
    {
        IList<PIMRepairInfo> allInfo = new List<PIMRepairInfo>();
        PIMRepairData all = new PIMRepairData();

        allInfo = all.GetPIMRepairData();
        return allInfo;
    }

    protected IList<PIMRepairInfo> GetDataInfo()
    {
        DateTime dt1 = DateTime.Parse(tbSta.Value.Trim());
        DateTime dt2 = DateTime.Parse(tbEnd.Value.Trim());
        IList<PIMRepairInfo> dateInfo = new List<PIMRepairInfo>();
        PIMRepairData rD = new PIMRepairData(); 
        dateInfo = rD.GetPIMRepairInfo(dt1, dt2);
        return dateInfo;
    }
}
